<!DOCTYPE html>
<!--
This is a starter template page. Use this page to start your new project from
scratch. This page gets rid of all links and provides the needed markup only.
-->
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>AdminLTE 2 | Starter</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <link rel="stylesheet" href="/stylesheets/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="/font-awesome/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="/stylesheets/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="/stylesheets/AdminLTE.min.css">
  <!-- AdminLTE Skins. We have chosen the skin-blue for this starter
        page. However, you can choose any other skin. Make sure you
        apply the skin class to the body tag so the changes take effect. -->
  <link rel="stylesheet" href="/stylesheets/skins/skin-blue.min.css">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Google Font -->
  <link rel="stylesheet"
        href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<!--
BODY TAG OPTIONS:
=================
Apply one or more of the following classes to get the
desired effect
|---------------------------------------------------------|
| SKINS         | skin-blue                               |
|               | skin-black                              |
|               | skin-purple                             |
|               | skin-yellow                             |
|               | skin-red                                |
|               | skin-green                              |
|---------------------------------------------------------|
|LAYOUT OPTIONS | fixed                                   |
|               | layout-boxed                            |
|               | layout-top-nav                          |
|               | sidebar-collapse                        |
|               | sidebar-mini                            |
|---------------------------------------------------------|
-->
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
  <%- include("./header.ejs")%>
  <!-- Main Header -->
  <!-- Left side column. contains the logo and sidebar -->
  <%- include("./sidebar.ejs")%>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        商品管理
        <small><a href="/pro/add" class="btn  btn-info btn-xs">添加商品信息</a>&nbsp;&nbsp;<a href="/pro/insertAll" class="btn  btn-info btn-xs">批量导入</a></small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Level</a></li>
        <li class="active">Here</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content container-fluid">

      <!--------------------------
        | Your Page Content Here |
        -------------------------->
        <div class="box">
          <div class="box-header">
            <h3 class="box-title">商品信息</h3>

            <div class="box-tools">
              <form action="/pro/search" method="post">
                <div class="input-group input-group-sm" style="width: 150px;">
                  <input type="text" name="search" class="form-control pull-right" placeholder="Search">

                  <div class="input-group-btn">
                    <button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
                  </div>
                </div>
              </form>
            </div>
          </div>
          <!-- /.box-header -->
          <div class="box-body table-responsive no-padding">
            <table class="table table-hover" >
              <tbody>
                <tr>
                  <th style="width: 60px; text-align: center;vertical-align: middle;">序号</th>
                  <th style="text-align: center;vertical-align: middle;">名称</th>
                  <th style="width: 100px;text-align: center;vertical-align: middle;">分类</th>
                  <th style="width: 100px;text-align: center;vertical-align: middle;">品牌</th>
                  <th style="width: 100px;text-align: center;vertical-align: middle;">Logo</th>
                  <th style="width: 100px;text-align: center;vertical-align: middle;">商品主图</th>
                  <th style="width: 100px;text-align: center;vertical-align: middle;">商品图片1</th>
                  <th style="width: 100px;text-align: center;vertical-align: middle;">商品图片2</th>
                  <th style="width: 60px;text-align: center;vertical-align: middle;position: relative;">价格
                    <div style="position: absolute;top: 0px;left: 65px;">
                      <a href="/pro/sort?price=1" style="display: block;height:12px;padding-top: 5px;"><i class="fa fa-sort-up "></i></a>
                      <a href="/pro/sort?price=-1"style="display: block;height:10px;"><i class="fa fa-sort-desc"></i></a>
                    </div>
                  </th>
                  <th style="text-align: center;vertical-align: middle;">介绍</th>
                  <th style="width: 60px;text-align: center;vertical-align: middle;position: relative;">库存
                    <div style="display: inline-block;position: absolute;top: 0px;left: 49px">
                      <a href="/pro/sort?stock=1" style="display: block;height:12px;padding-top: 5px;"><i class="fa fa-sort-up "></i></a>
                      <a href="/pro/sort?stock=-1"style="display: block;height:10px;"><i class="fa fa-sort-desc"></i></a>
                    </div>
                  </th>
                  <th style="width: 60px;text-align: center;vertical-align: middle;position: relative;">销量
                    <div style="display: inline-block;position: absolute;top: 0px;left: 49px">
                      <a href="/pro/sort?sales=1" style="display: block;height:12px;padding-top: 5px;"><i class="fa fa-sort-up "></i></a>
                      <a href="/pro/sort?sales=-1"style="display: block;height:10px;"><i class="fa fa-sort-desc"></i></a>
                    </div>
                  </th>
                  <th style="width: 60px;text-align: center;vertical-align: middle;position: relative;">折扣
                    <div style="display: inline-block;position: absolute;top: 0px;left: 49px">
                      <a href="/pro/sort?discount=1" style="display: block;height:12px;padding-top: 5px;"><i class="fa fa-sort-up "></i></a>
                      <a href="/pro/sort?discount=-1"style="display: block;height:10px;"><i class="fa fa-sort-desc"></i></a>
                    </div>

                  </th>
                  <th style="width: 60px;text-align: center;vertical-align: middle;position: relative;">评分
                    <div style="display: inline-block;position: absolute;top: 0px;left: 49px">
                      <a href="/pro/sort?score=1" style="display: block;height:12px;padding-top: 5px;"><i class="fa fa-sort-up "></i></a>
                      <a href="/pro/sort?score=-1"style="display: block;height:10px;"><i class="fa fa-sort-desc"></i></a>
                    </div>

                  </th>
                  <th style="width: 100px;text-align: center;vertical-align: middle;">操作</th>
                </tr>
                <% for(var i=0;i<data.length;i++){ %>
                <tr>
                  <td style="text-align: center;height: 70px;line-height: 70px;"><%= pageIndex*dataNum +(i+1) %></td>
                  <td style="height: 70px;width: 150px ;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;display: block;line-height: 70px;"><%= data[i].proName %></td>
                  <td style="text-align: center;height: 70px;line-height: 70px;"><%= data[i].column %></td>
                  <td style="text-align: center;height: 70px;line-height: 70px;"><%= data[i].brand %></td>
                  <td style="text-align: center;height: 70px;line-height: 70px;vertical-align: middle;"><img width="40" src="<%= data[i].logo %>" alt=""></td>
                  <td style="text-align: center;height: 70px;line-height: 70px;vertical-align: middle;"><img width="40" src="<%= data[i].mainImg %>" alt=""></td>
                  <td style="text-align: center;height: 70px;line-height: 70px;vertical-align: middle;"><img width="40" src="<%= data[i].proImg1 %>" alt=""></td>
                  <td style="text-align: center;height: 70px;line-height: 70px;vertical-align: middle;"><img width="40" src="<%= data[i].proImg2 %>" alt=""></td>
                  <td style="text-align: center;height: 70px;line-height: 70px;"><%= data[i].price %></td>
                  <td style="height: 70px; width: 240px; vertical-align: middle;">
                    <span style="display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 3;overflow: hidden;width:100%;"><%= data[i].introduce %></span>
                  </td>
                  <td style="text-align: center;height: 70px;line-height: 70px;"><%= data[i].stock %></td>
                  <td style="text-align: center;height: 70px;line-height: 70px;"><%= data[i].sales %></td>
                  <td style="text-align: center;height: 70px;line-height: 70px;"><%= data[i].discount %></td>
                  <td style="text-align: center;height: 70px;line-height: 70px;"><%= data[i].score %></td>
                  <td style="text-align: center;height: 70px;line-height: 70px;">
                    <a href="/pro/update?id=<%= data[i].proId %>" class="btn  btn-warning btn-xs" style="width: 30px;">修改</a>
                    <a href="/pro/delete?id=<%= data[i].proId %>" class="btn  btn-danger btn-xs " style="width: 30px;">删除</a>
                  </td>
                </tr>
                <% } %>
              </tbody>
            </table>
          </div>
          <!-- /.box-body -->
          <div class="box-footer clearfix" style="width: 100%;">
            <ul class="pagination pagination-sm no-margin pull-right mx-auto" >
              <li><a onclick="prev('<%= pageIndex %>')">«</a></li>
              <% for(var i=0;i<maxPage;i++){ %>
                <li class="<%= pageIndex==i? 'active':'' %>"><a href="/pro/page?index=<%=i %>&num=10"><%=i+1 %></a></li>
                <% } %>
              <li><a onclick="next('<%= pageIndex %>','<%= maxPage %>')">»</a></li>
            </ul>
          </div>
        </div>    

    </section>
    <script>
      // var j = (location.search).split("&")[0].split("=")[1];
      function prev(a){
        if(a>0){
          a--;
          location.href = `/pro/page?index=${a}&num=10`;
        }
      }
      function next(a,maxpage){
        maxpage=maxpage*1;
        a=a*1;
        if(a<maxpage-1){//最大页码-1才是页码索引
          a++;
          console.log(a,maxpage)
          location.href = `/pro/page?index=${a}&num=10`;
         }

      }

    </script>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <!-- Main Footer -->
  <%- include("./footer.ejs")%>
  <!-- Control Sidebar -->
  <!-- /.control-sidebar -->
  <%- include("./rightsidebar.ejs")%>

  <!-- Add the sidebar's background. This div must be placed
  immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

<!-- REQUIRED JS SCRIPTS -->

<!-- jQuery 3 -->
<script src="/javascripts/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="/javascripts/bootstrap.min.js"></script>
<!-- AdminLTE App -->
<script src="/javascripts/adminlte.min.js"></script>

<!-- Optionally, you can add Slimscroll and FastClick plugins.
     Both of these plugins are recommended to enhance the
     user experience. -->
</body>
</html>